
//
//  CinemaCell.m
//  第六组电影项目
//
//  Created by mini on 14-7-3.
//  Copyright (c) 2014年 www.skedu.com.cn北京尚德智远科技有限公司. All rights reserved.
//

#import "CinemaCell.h"
#import "CinemaModel.h"
@implementation CinemaCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        self.selectionStyle=UITableViewCellSelectionStyleNone;
        [self initSubViews];
        // Initialization code
    }
    return self;
}
-(void)initSubViews
{
    //图像
    image=[[UIImageView alloc]initWithFrame:CGRectZero];
    [self.contentView addSubview:image];
    
    //标题
    title=[[UILabel alloc]initWithFrame:CGRectZero];
    title.font=[UIFont boldSystemFontOfSize:16];
    [self.contentView addSubview:title];
    
    
    //类型
    type=[[UILabel alloc]initWithFrame:CGRectZero];
    type.font=[UIFont boldSystemFontOfSize:14];
    type.textColor=[UIColor lightGrayColor];
    [self.contentView addSubview:type];
    
    //导演
    director=[[UILabel alloc]initWithFrame:CGRectZero];
    director.font=[UIFont boldSystemFontOfSize:14];
    director.textColor=[UIColor lightGrayColor];
    [self.contentView addSubview:director];
    //上映日期
    releaseDate=[[UIImageView alloc]initWithFrame:CGRectZero];
    releaseDate.image=[UIImage imageNamed:@"theater_coming"];
    [self.contentView addSubview:releaseDate];

    //月份
    monthLabel=[[UILabel alloc]initWithFrame:CGRectZero];
    monthLabel.font=[UIFont boldSystemFontOfSize:16];
    monthLabel.textColor=[UIColor whiteColor];
    monthLabel.textAlignment=NSTextAlignmentCenter;
    [releaseDate addSubview:monthLabel];
    //日
    dayLabel=[[UILabel alloc]initWithFrame:CGRectZero];
    dayLabel.font=[UIFont boldSystemFontOfSize:14];
    dayLabel.textColor=[UIColor blackColor];
    dayLabel.textAlignment=NSTextAlignmentCenter;
    [releaseDate addSubview:dayLabel];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    image.frame=CGRectMake(10, 10, 60, 80);
    [image setImageWithURL:[NSURL URLWithString:_cinemaModel.image]];
    
    title.frame=CGRectMake(image.right+10, image.top, 180, 25);
    title.text=_cinemaModel.title;

    type.frame=CGRectMake(image.right+10, title.bottom, 130, 25);
    type.text=_cinemaModel.type;

    director.frame=CGRectMake(image.right+10, type.bottom, 180, 25);
    director.text=_cinemaModel.director;
    
    //处理日期字符串(7月10日上映)
    releaseDate.frame=CGRectMake(kDeviceWidth - 100, title.bottom, 50, 50);
    monthLabel.frame=CGRectMake(0, 0, 50, 25);
    dayLabel.frame=CGRectMake(0, monthLabel.bottom, 50, 25);
    char *ch=(char *)[_cinemaModel.releaseDate UTF8String];
    int month,day;
    sscanf(ch,"%d月%d日",&month,&day);
    monthLabel.text=[NSString stringWithFormat:@"%d月",month];
    dayLabel.text=[NSString stringWithFormat:@"%d",day];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end
